package test.br.com.lh.urabuilder.business
{
	import br.com.lh.urabuilder.business.ViewManager;
	import br.com.lh.urabuilder.business.ViewManagerImpl;
	import br.com.lh.urabuilder.view.ActionComponent;
	
	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;
	
	import mx.containers.Canvas;
	import mx.core.UIComponent;
	
	public class ViewManagerImplTest extends TestCase
	{
		private var parent:UIComponent = new Canvas();
		
		  public function ViewManagerImplTest( methodName:String ) {
                super( methodName );
            }
      
           public static function suite():TestSuite {
                var ts:TestSuite = new TestSuite();
                ts.addTest( new ViewManagerImplTest("shouldSelectAllSubjacentArrows"));
                ts.addTest( new ViewManagerImplTest("simpleSelectionTest"));
                return ts;
          }
          
          public function simpleSelectionTest():void{
          	var viewManager:ViewManager = new ViewManagerImpl(parent);
          	var component:ActionComponent = new ActionComponent();
          	component.loadComponent("ws",10,10,1);
          	viewManager.insertComponent(component);
          	viewManager.selectComponent(component,true,false);
          	assertTrue(viewManager.getSelectedComponents().length==1);
          	viewManager.selectComponent(component,false,false);
          	assertTrue(viewManager.getSelectedComponents().length==0);
          }
          
          
          public function shouldSelectAllSubjacentArrows():void{
          	var viewManager:ViewManager = new ViewManagerImpl(parent);
          	var component:ActionComponent = new ActionComponent();
          	component.loadComponent("ws",10,10,1);
          	var component2:ActionComponent = new ActionComponent();
          	component2.loadComponent("ws",20,20,2);
          	viewManager.insertComponent(component);
          	viewManager.insertComponent(component2);
          	viewManager.drawArrow(component,component2);
          	viewManager.selectComponent(component,true,false);
          	assertTrue(viewManager.getSelectedComponents().length==2);
          }

	}
}